{% extends "pretixpresale/event/base.html" %}
{% load i18n %}
{% load bootstrap3 %}
{% load rich_text %}
{% block title %}{% trans "Modify order" %}{% endblock %}
{% block content %}
    <h2>
        {% blocktrans trimmed with code=order.code %}
            Modify order: {{ code }}
        {% endblocktrans %}
    </h2>
    <form class="form-horizontal" method="post" enctype="multipart/form-data">
        {% csrf_token %}
        <div class="panel-group" id="questions_accordion">
            {% if invoice_address_asked or event.settings.invoice_name_required %}
                {% if invoice_address_asked and not request.GET.generate_invoice == "true" and not event.settings.invoice_reissue_after_modify %}
                    <div class="alert alert-info">
                        {% blocktrans trimmed %}
                            Modifying your invoice address will not automatically generate a new invoice.
                            Please contact us if you need a new invoice.
                        {% endblocktrans %}
                    </div>
                {% endif %}
                <details class="panel panel-default" open>
                    <summary class="panel-heading">
                        <h4 class="panel-title">
                            <strong>
                                {% if invoice_address_asked %}
                                    {% trans "Invoice information" %}{% if not event.settings.invoice_address_required %}
                                        {% trans "(optional)" %}
                                    {% endif %}
                                {% else %}
                                    {% trans "Contact information" %}
                                {% endif %}
                            </strong>
                            <i class="fa fa-angle-down collapse-indicator" aria-hidden="true"></i>
                        </h4>
                    </summary>
                    <div id="invoice" class="panel-collapse">
                        <div class="panel-body">
                            {% if event.settings.invoice_address_explanation_text %}
                                <div>
                                    {{ event.settings.invoice_address_explanation_text|rich_text }}
                                </div>
                            {% endif %}
                            {% bootstrap_form invoice_form layout="horizontal" %}
                        </div>
                    </div>
                </details>
            {% endif %}
            {% for pos, forms in formgroups %}
                <details class="panel panel-default" open>
                    <summary class="panel-heading">
                        <h4 class="panel-title">
                            <strong>{{ pos.item.name }}{% if pos.variation %}
                                – {{ pos.variation }}
                            {% endif %}</strong>
                            <i class="fa fa-angle-down collapse-indicator" aria-hidden="true"></i>
                        </h4>
                    </summary>
                    <div id="cp{{ pos.id }}">
                        <div class="panel-body questions-form">
                            {% for form in forms %}
                                {% if form.pos.item != pos.item %}
                                    {# Add-Ons #}
                                    <legend>+ {{ form.pos.item }}</legend>
                                {% endif %}
                                {% bootstrap_form form layout="checkout" %}
                            {% endfor %}
                        </div>
                    </div>
                </details>
            {% endfor %}
        </div>
        <div class="row checkout-button-row">
            <div class="col-md-4">
                <a class="btn btn-block btn-default btn-lg"
                        href="{{ view.get_order_url }}">
                    {% trans "Cancel" %}
                </a>
            </div>
            <div class="col-md-4 col-md-offset-4">
                <button class="btn btn-block btn-primary btn-lg" type="submit">
                    {% if request.GET.generate_invoice == "true" %}
                        {% trans "Request invoice" %}
                    {% else %}
                        {% trans "Save changes" %}
                    {% endif %}
                </button>
            </div>
            <div class="clearfix"></div>
        </div>
    </form>
{% endblock %}
